package com.wechat.app.ui.screens.discover

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.*
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.wechat.app.ui.navigation.navigateToMoments

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun DiscoverScreen(modifier: Modifier = Modifier) {
    val items = listOf(
        "朋友圈" to Icons.Default.PhotoCamera,
        "扫一扫" to Icons.Default.QrCodeScanner,
        "摇一摇" to Icons.Default.Vibration,
        "看一看" to Icons.Default.Visibility,
        "搜一搜" to Icons.Default.Search
    )
    
    Scaffold(
        topBar = {
            TopAppBar(
                title = { Text("发现") },
                colors = TopAppBarDefaults.topAppBarColors(
                    containerColor = MaterialTheme.colorScheme.background
                )
            )
        }
    ) { paddingValues ->
        LazyColumn(
            modifier = modifier
                .fillMaxSize()
                .padding(paddingValues)
        ) {
            items(items) { (label, icon) ->
                DiscoverItem(
                    label = label, 
                    icon = icon,
                    onClick = {
                        if (label == "朋友圈") {
                            navigateToMoments()
                        }
                        // 其他功能可以在这里添加
                    }
                )
                if (label != items.last().first) {
                    Divider()
                }
            }
        }
    }
}

@Composable
fun DiscoverItem(
    label: String, 
    icon: androidx.compose.ui.graphics.vector.ImageVector,
    onClick: () -> Unit = {}
) {
    Row(
        modifier = Modifier
            .fillMaxWidth()
            .clickable(onClick = onClick)
            .padding(horizontal = 16.dp, vertical = 16.dp),
        verticalAlignment = Alignment.CenterVertically
    ) {
        Icon(
            imageVector = icon,
            contentDescription = label,
            tint = MaterialTheme.colorScheme.primary
        )
        Spacer(modifier = Modifier.width(16.dp))
        Text(
            text = label,
            style = MaterialTheme.typography.bodyLarge,
            modifier = Modifier.weight(1f)
        )
        Icon(
            imageVector = Icons.Default.ChevronRight,
            contentDescription = null,
            tint = MaterialTheme.colorScheme.onSurfaceVariant
        )
    }
}

